package com.easycoding.ums.system.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.easycoding.ums.support.BaseEntity;;


/**
 * 角色信息表
 * @author Wangjk
 * @Version 1.0
 * @Date 2013-4-1
 */
@Entity
@Table(name="role_info")
public class Role extends BaseEntity{

	/**
	 * 
	 */
	private static final long serialVersionUID = -430400894625071223L;
	
	
	/**
	 * 角色名
	 */
	@Column(name="role_name")
	private String name;
	
	/**
	 * 角色用户
	 */
	@OneToMany(mappedBy="role",cascade={CascadeType.ALL},fetch=FetchType.LAZY)
	private Set<UserRole> roleUsers = new HashSet<UserRole>();
	
	/**
	 * 角色权限
	 */
	@OneToMany(mappedBy="role",cascade={CascadeType.ALL},fetch=FetchType.EAGER)
	private Set<RolePermission> userPermissions = new HashSet<RolePermission>();
	
	/**
	 * 获取角色名
	 * @return name 角色名
	 */
	public String getName() {
		return name;
	}


	/**
	 * 设置角色名
	 * @param name 角色名
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * 获取角色权限
	 * @return userPermissions 角色权限
	 */
	public Set<RolePermission> getUserPermissions() {
		return userPermissions;
	}


	/**
	 * 设置角色权限
	 * @param userPermissions 角色权限
	 */
	public void setUserPermissions(Set<RolePermission> userPermissions) {
		this.userPermissions = userPermissions;
	}


	/**
	 * 获取角色用户
	 * @return roleUsers 角色用户
	 */
	public Set<UserRole> getRoleUsers() {
		return roleUsers;
	}


	/**
	 * 设置角色用户
	 * @param roleUsers 角色用户
	 */
	public void setRoleUsers(Set<UserRole> roleUsers) {
		this.roleUsers = roleUsers;
	}
	
}
